{include file="common/_meta" /}
<link rel="stylesheet" href="/static/viewer.min.css">
<title></title>
</head>
<body class="pos-r">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 交易管理 <span class="c-gray en">&gt;</span> 交易大厅记录 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		<form class="Huiform" method="get" action="" >
		<div class="text-c"> 
			状态：
			<span class="select-box inline">
				<select name="status" class="select">
					<option value="" >全部</option> 
					<option value="0" >待打款</option> 
					<option value="1" >待确认收款</option> 
					<option value="2" style="color:green;">交易完成</option>
				</select>
			</span>
			日期范围：
			<input type="text" class="input-text Wdate" name="start" id="countTimestart" onfocus="selecttime(1)" value="{$Request.get.start|default=''}" size="17" class="date" readonly style="width:140px;"> 
			- 
			<input type="text" class="input-text Wdate" name="end" id="countTimeend" onfocus="selecttime(2)" value="{$Request.get.end|default=''}" size="17"  class="date" readonly style="width:140px;">
			<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
		</div>
		</form>
		<div class="cl pd-5 bg-1 bk-gray mt-20"><span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
		<div class="mt-20">
			<table class="table table-border table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th ><input name="" type="checkbox" value=""></th>
						<th >ID</th>
						<th>卖家信息</th>
						<th>买家信息</th>
						<th>挂卖金额</th>
						<th>手续费</th>
						<th>应转账</th>
						<th>买入打款凭证 </th>
						<th>交易时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="vo"}
					<tr class="text-c va-m">
						<td><input name="" type="checkbox" value=""></td>
						<td>{$vo.trade_no}</td>
						<td>{$vo.seller.name}<br/>{$vo.seller.tel}</td>
						<td>{$vo.buyer.name}<br/>{$vo.buyer.tel}</td>
						<td>{$vo.trade_num}</td>
						<td>{$vo.fee}</td>
						<td style="color:green;">{$vo.trade_num - $vo.fee}</td>
						<td><img  style="width: 40px;height: 40px" class="product-thumb image" src="{$vo.voucher|default='/upload/default.jpg'}" alt=""></td>
						<td>创建时间：{$vo.create_time}<br/>更新时间：{$vo.update_time}</td>
						<td class="td-status">
							{switch name="$vo.status" }
							    {case value="0" }<span class="label label-default radius">待买入</span>{/case}
							    {case value="1"}<span class="label label-secondary radius">待确认收款</span>{/case}
							    {case value="2"}<span class="label label-success radius">交易完成</span>{/case}
							    {case value="-1"}{/case}
							{/switch}
						</td>
						<td class="td-manage">
							{if condition="$vo['status'] eq 1"}
                                <a style="text-decoration:none" onClick="confirm(this,{$vo.id})" href="javascript:;" title="确认收款">
                                    <i class="Hui-iconfont">&#xe6a7;</i>
                                </a>
                            {elseif condition="$vo['status'] eq 0"}
                                <a style="text-decoration:none" onClick="reject(this,{$vo.id})" href="javascript:;" title="驳回转账申请">
                                    <i class="Hui-iconfont">&#xe6a6;</i>
                                </a>
                            {else/}
                            {/if}
							

						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div class="pages" style="margin:20px;float: right; ">{$list->render()}</div>
		</div>
	</div>
</div>
{include file="common/_footer" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script src="/static/viewer.min.js"></script>
<script type="text/javascript">
$('.image').viewer(); 
$('select[name="status"]').val('{$Request.get.status}');
function selecttime(flag){
    if(flag==1){
        var endTime = $("#countTimeend").val();
        if(endTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',maxDate:endTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }else{
        var startTime = $("#countTimestart").val();
        if(startTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',minDate:startTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }
 }
function opt(obj,title,id,type){
	layer.confirm('确认'+title,function(index){
		$.post("{:url('Deal/shopCashOut')}",{id:id,type:type}).success(function(data){
			layer.msg(data.msg,{icon: 6,time:1000});
			if(data.code){
				setTimeout(function(){
					history.go(0);
				},500);
			}
		});
	});
}

// 代替玩家确认收款
 function confirm(obj, id) {
   layer.confirm('代替玩家确认收款吗', {btn: ['确认','取消'] //按钮
    }, function(){
        $.post("{:url('Deal/sellList')}?act=confirm", {id: id}).success(function (data) {
            layer.msg(data.msg);
            if (data.code) {
                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已完成</span>');
                $(obj).remove();
            }
        });
    });
}

function reject(obj, id) {
    // 发货
   layer.confirm('代替代理驳回转账请求吗', {btn: ['确认','取消'] //按钮
    }, function(){
        $.post("{:url('Deal/sellList')}?act=cancle", {id: id}).success(function (data) {
            layer.msg(data.msg);
            if (data.code) {
                $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已驳回</span>');
                $(obj).remove();
            }
        });
    });
}


</script>
</body>
</html>